module uart_top (
    input               clk_50m,
    input               rst_n,
    input               rx,
    output              tx,
    output [7:0]        led
);

    wire [7:0] data;
    wire done;
    wire busy_rx, busy_tx;
    wire delay_rx, delay_tx;

    assign led[0] = ~delay_rx;
    assign led[1] = ~delay_tx;

    // 延迟高电平，用于闪灯
    delay led_flash (
        .clk_50m            (clk_50m),
        .rst_n              (rst_n),
        .plus               (busy_rx),
        .count_ms           (100),
        .delay              (delay_rx)
    );

    delay led_flash2 (
        .clk_50m            (clk_50m),
        .rst_n              (rst_n),
        .plus               (busy_tx),
        .count_ms           (100),
        .delay              (delay_tx)
    );

    // 接收模块
    uart_rx inst_rx (
        .clk_50m            (clk_50m),
        .rst_n              (rst_n),
        .rx                 (rx),
        .q                  (data),
        .done               (done),
        .err                (),
        .busy               (busy_rx)
    );

    // 发送模块
    uart_tx inst_tx (
        .clk_50m            (clk_50m),
        .rst_n              (rst_n),
        .data               (data),
        .enable             (done),
        .busy               (busy_tx),
        .tx                 (tx)
    );

endmodule  //uart_top